package com.fzrskj.cloud.free.api;

import lombok.Data;
import org.apache.commons.lang.StringUtils;

@Data
public class PayForm {
	private String name;
	private String version;
	private String charset;
	private String msgSender;
	private String riskExtItems;
	private String sendTime;
	private String orderNo;
	private String orderAmount;
	private String orderTime;
	private String payType;
	private String payChannel;
	private String instCode;
	private String pageUrl;
	private String notifyUrl;
	private String productName;
	private String buyerContact;
	private String buyerIp;
	private String ext1;
	private String signType;
	private String signMsg;


	public PayForm() {
		name = "B2CPayment";
		version = "V4.1.1.1.1";

	}

	public String toSignString() {
		StringBuffer buf = new StringBuffer();
		buf.append(StringUtils.isNotEmpty(name) ? name+"|" : "");
		buf.append(StringUtils.isNotEmpty(version) ? version+"|" : "");
		buf.append(StringUtils.isNotEmpty(charset) ? charset+"|" : "");
		buf.append(StringUtils.isNotEmpty(msgSender) ? msgSender+"|" : "");
		buf.append(StringUtils.isNotEmpty(riskExtItems)?riskExtItems+"|":"");
		buf.append(StringUtils.isNotEmpty(sendTime) ? sendTime+"|" : "");
		buf.append(StringUtils.isNotEmpty(orderNo) ? orderNo+"|" : "");
		buf.append(StringUtils.isNotEmpty(orderAmount) ? orderAmount+"|" : "");
		buf.append(StringUtils.isNotEmpty(orderTime) ? orderTime+"|" : "");
		buf.append(StringUtils.isNotEmpty(payType) ? payType+"|" : "");
		buf.append(StringUtils.isNotEmpty(payChannel)? payChannel+"|" : "");
		buf.append(StringUtils.isNotEmpty(instCode) ? instCode+"|" : "");
		buf.append(StringUtils.isNotEmpty(pageUrl) ? pageUrl+"|" : "");
		buf.append(StringUtils.isNotEmpty(notifyUrl) ? notifyUrl+"|" : "");
		buf.append(StringUtils.isNotEmpty(productName) ? productName+"|" : "");
		buf.append(StringUtils.isNotEmpty(buyerContact) ? buyerContact+"|" : "");
		buf.append(StringUtils.isNotEmpty(buyerIp) ? buyerIp+"|" : "");
		buf.append(StringUtils.isNotEmpty(ext1) ? ext1+"|" : "");
		buf.append(StringUtils.isNotEmpty(signType) ? signType+"|" : "");
		return buf.toString();

	}
	
	/**
	 * 直连，不显示收银台
	 * @param payType
	 * @param instCode
	 */
	public void setDirectPay(String payType,String instCode){
		this.payType = payType;
		this.instCode = instCode;
	}
}